package lzzy.edu.cn.demothymeleaf.repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lzzy.edu.cn.demothymeleaf.entity.Customer;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface   CustomerRepository extends JpaRepository<Customer,Integer> {

    @Query("select c from t_customer c where c.username =?1")
    public Customer findCustomerByUsername(String username);

    //    代码的功能是：定义一个查询，用于计算并返回与给定文章ID相关联的评论数量。这对于实现如显示文章详情时展示该文章收到的评论数等功能
    @Query("SELECT COUNT(c) FROM t_comment c WHERE c.aId = :aId")
    int countCommentsByArticleId(@Param("aId") int aId);


}